<?php
defined('IN_TS') or die('Access Denied.');

//用户空间

$duserid = intval($_GET['userid']);

$strUser = $new['user']->getOneUserByUserid($duserid);

//是否关注
if($TS_USER['user']['userid'] != '' && $TS_USER['user']['userid'] != $strUser['userid']){
	$followNum = $db->once_num_rows("select * from ".dbprefix."user_follow where userid='".$TS_USER['user']['userid']."' and userid_follow='$duserid'");
	if($followNum > '0'){
		$strUser['isfollow'] = true;
	}else{
		$strUser['isfollow'] = false;
	}
}else{
	$strUser['isfollow'] = false;
}

//他关注的用户
$followUsers = $db->fetch_all_assoc("select userid_follow from ".dbprefix."user_follow where userid='$duserid' order by addtime limit 12");

if(is_array($followUsers)){
	foreach($followUsers as $item){
		$arrFollowUser[] =  $new['user']->getOneUserByUserid($item['userid_follow']);
	}
}

//关注他的用户
$followedUsers = $db->fetch_all_assoc("select userid from ".dbprefix."user_follow where userid_follow='$duserid' order by addtime limit 8");
$followedUsersum = $db->fetch_all_assoc("select userid from ".dbprefix."user_follow where userid_follow='$duserid'");
$followedUsersnum = count($followedUsersum);
if(is_array($followedUsers)){
	foreach($followedUsers as $item){
		$arrFollowedUser[] =  $new['user']->getUserForApp($item['userid']);
	}
}


//加入的秀店
$arrGroups = $db->fetch_all_assoc("select * from ".dbprefix."group_users where userid='$duserid' limit 12");

if(is_array($arrGroups)){
	foreach($arrGroups as $key=>$item){
		$arrGroup[] = aac('group')->getOneGroup($item['groupid']);
	}
}

//自己的宝贝 
$arrMyTopic = $db->fetch_all_assoc("select * from ".dbprefix."group_topics where userid='$duserid' order by addtime desc limit 15");

$arrMyAllTopic = $db->fetch_all_assoc("select * from ".dbprefix."group_topics where userid='$duserid'");
$annmu=count($arrMyAllTopic);
//回复的宝贝 
$arrComments = $db->fetch_all_assoc("select topicid from ".dbprefix."group_topics_comments where userid='$duserid' group by topicid order by addtime desc limit 15");
if(is_array($arrComments)){
	foreach($arrComments as $item){
		$oneTopic = $db->once_fetch_assoc("select * from ".dbprefix."group_topics where topicid='".$item['topicid']."'");
		if($oncTopic['userid'] != $duserid){
			$arrMyComment[] = $oneTopic;
		}
		
	}

}
//发布的话题 
		$page = isset($page) ? intval($page) : 1;
		$lstart = $page*10-10;
	$sql = "select talkid,typeid,userid,title,count_comment,count_view,istop,isphoto,isattach,isposts,addtime,uptime from ".dbprefix."talk_topics where isshow='0' and userid=".$duserid." order by istop desc,uptime desc limit $lstart,10";
	$arrTopics = $db->fetch_all_assoc($sql);
		if( is_array($arrTopics)){
		foreach($arrTopics as $key=>$item){
			$arrTopics[$key]['user'] = aac('user')->getSimpleUser($item['userid']);
		}
	}
		$collects_num = $db->once_num_rows("select * from ".dbprefix."group_topics_collects where userid=".$duserid."");
	$talk_num = $db->once_num_rows("select count(talkid) from ".dbprefix."talk_topics where userid=".$duserid."");
	$userid = intval($TS_USER['user']['userid']);
	$pageUrl = paginationv($talk_num['count(talkid)'], 10, $page, $url);

$title = $strUser['username'].'的话题';
include template("talk");
